home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: metropolis.nl!news
- From: Wilfred van Breda <wbreda@ib.com>
- Subject: Length of text on printers in Windows
- X-Nntp-Posting-Host: ppp0-131.metropolis.nl
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <3147E497.13ED@ib.com>
- Sender: news@news.metropolis.nl (usenet)
- Content-Transfer-Encoding: 7bit
- Organization: Tree Star Automation
- Mime-Version: 1.0
- Date: Thu, 14 Mar 1996 09:19:19 GMT
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- I have a problem calculating the correct length of a line of text
- in Windows. When I want to calculate the length I consistently get
- the width of the text as appears on screen and not as it appears
- on paper. I need this information to determine if a line of text
- will fit on paper so I can take appropriate action if it does not.
-
- The code I use is:
-
- hdc = GetPrinterIC();
-
- MapModePrevious = SetMapMode(hdc, MM_TEXT);
-
- hfont = CreateFont(-pointsize,0,0,0,weight,italic,0,0,0,0,0,0,0,font);
- hfontold=SelectObject(hdc,hfont);
-
- dwExtent = GetTextExtent(hdc, text, textlen);
-
- wTextWidth = LOWORD(dwExtent);
-
- SetMapMode(hdc, MapModePrevious);
- SelectObject(hdc,hfontold);
- DeleteObject(hfont);
- DeleteDC(hdc);
-
-
- The font I want to use is either Arial or Times New Roman.
-
- Help would be much appreciated.
-
- Wilfred van Breda
-